<!DOCTYPE html>
<html>
<head>
<title>代码生成器</title>
<#include "/header.html">
</head>
<body>
	<form >
		<input type="text" id="id" name="id" hidden="true" value=""/><br>
		标签名称：<input type="text" id="tag_name" name="tagName" value=""/><br>
		标签简介：<input type="text" id="description" name="description" value=""/><br>
		<!-- <input type="submit" name="submit" value="提交"/> -->
		<button onclick="formLabelAddUpdate()">提交</button>
		<button type="button"  >取消</button> 
	</form>
<script type="text/javascript">
	function formLabelAddUpdate(){
		var subject_flag = 0;
		var id = document.getElementById("id").value;
		var tag_name_obj = document.getElementById("tag_name").value;
		var description_obj = document.getElementById("description").value;
		var dataJson = {"id":id,"tagName":tag_name_obj,"description":description_obj};
		if(subject_flag==0){
			$.ajax({
				url : baseURL + "book/label/saveOrUpdateLabel",
				type : 'POST',
				data : JSON.stringify(dataJson),
				contentType : "application/json; charset=utf-8",
				dataType : 'text',
				success : function(result) {
					parent.location.href = './book-label.html';
					console.log(result);
					subject_flag=1;
					layer.closeAll();
					if (result.detail != null) {
						layer.msg(result.detail.message, {
							icon : -1
						});
					} else {
						layer.msg("提交成功", {
							icon : -1
						});
						layer.closeAll();
					} 
					//vm.reload();
				 },
				error:function(result){
					console.log(result);
					parent.location.href = './book-label.html';
				}
			}); 
		}
	}
</script>
</body>
</html>